﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TestOnlineProject.Models.BusinessLogic;
using TestOnlineProject.Models.Entities;

namespace TestOnlineProject.Areas.Admin.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        SubjectBLO subjectBLO = new SubjectBLO();
        TestBLO testBLO = new TestBLO();
        SectionBLO sectionBLO = new SectionBLO();
        QuestionBLO questionBLO = new QuestionBLO();
        DiscussionBLO discussionBLO = new DiscussionBLO();

        public ActionResult Index()
        {
            try
            {
                if (TempData["Msg"] != null)
                {
                    ViewBag.Msg = TempData["Msg"];
                }
                var subjects = subjectBLO.Recommend();
                var tests = testBLO.Recommend();
                var sections = sectionBLO.Recommend();
                var questions = questionBLO.Recommend();
                var discussions = discussionBLO.Recommend();
                ViewBag.Subjects = subjects;
                ViewBag.Test = tests;
                ViewBag.Sections = sections;
                ViewBag.Questions = questions;
                ViewBag.Discussions = discussions;
                var Sections = sections;
                return View();
            }
            catch (Exception)
            {
                // Write to log file.
                return RedirectToAction("Index", "Error");
            }
        }

        public ActionResult Overview()
        {
            return View();
        }

        public ActionResult Feedback()
        {
            return RedirectToAction("Create", "Feedback");
        }

        public ActionResult Contact()
        {
            return View();
        }

        public ActionResult ChangeView(string view = "")
        {
            switch (view)
            {
                case "student":
                    Session["StudentView"] = "student";
                    break;
                default:
                    Session["StudentView"] = null;
                    break;
            }
            return RedirectToAction("Index");
        }
    }
}
